package com.tuan.jenkins_demo.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
 */
@Controller
public class PathVariableController {

  // http://127.0.0.1:8080/user/123/roles/222
  @RequestMapping(value = "/user/{userId}/roles/{roleId}", method = RequestMethod.GET)
  @ResponseBody
  public String getLogin(
      @PathVariable("userId") String userId, @PathVariable("roleId") String roleId) {
    return "com.tuan.jenkins_demo.web.User Id : " + userId + " Role Id : " + roleId;
  }

  // http://127.0.0.1:8080/javabeat/somewords
  @RequestMapping(value = "/javabeat/{regexp1:[a-z-]+}", method = RequestMethod.GET)
  @ResponseBody
  public String getRegExp(@PathVariable("regexp1") String regexp1) {
    return "URI Part : " + regexp1;
  }
}
